In this part, we are interested in looking at the central park squirrel census collected in October 2018. We make this graph to analysis the frequency of squirrels recorded for each of the observation (AM or PM).
dates =
census %>%
mutate(Month = substr(date, 1,2), Day = substr(date, 3,4), Year = substr(date,5,9))
dates %>%
group_by(Day, shift) %>%
count() %>%
ggplot() +
geom_col(aes(x = Day, y = n, fill = shift)) +
scale_fill_brewer(palette = "Paired") +
labs(x = "Day", y = "Number of Observations", fill = 'Shift') +
ggtitle('Central Park Squirrels Distribution by Days (AM/PM)') +
theme(plot.title = element_text(hjust = 0.5)) +
labs(fill='Time of day')
First graph we drew was ‘Number of Observations’ v.s. ‘Day’, and morning and afternoon data were separated and found out that squirrels tend to be more active in the afternoon or at night time. However, the limitation of the data is that we were not able to get the exact time period of their activities but only either morning or evening, we can assume they are present prior to sunset since they should be busy collecting the food when there is sunlight.
In this part, we make this graph to analysis the frequency of squirrels recorded for each of the observation by primary fur color.
dates %>%
group_by(Day, primary_fur_color) %>%
count() %>%
ggplot() +
geom_col(aes(x = Day, y = n, fill = primary_fur_color)) +
scale_fill_brewer(palette = "Paired") +
ggtitle('Central Park Squirrels Distribution by Primary Fur Color') +
theme(plot.title = element_text(hjust = 0.5)) +
labs( x='Day', y= 'Number of Observations') +
labs(fill='Primary Fur Color') +
scale_fill_manual(values = c("#000000", "#D2691E", "#D3D3D3", "white"))
In this part, we make this pie chart to display the percentage of squirrels by age group.
pie_1 =
dates %>%
filter(age !='?') %>%
group_by(age) %>%
count()
pie_1 %>%
mutate(prop = percent(n/sum(pie_1$n))) %>%
ggplot(aes(x="", y = n, fill = age)) +
geom_bar(stat="identity", width=1, color="white") +
coord_polar("y", start = 0, direction = 1) +
theme_void() +
ggtitle('Squirrels Distribution by Age Group') +
geom_text(aes(label = prop),position = position_stack(vjust = 0.5)) +
scale_fill_brewer()